﻿using ProtocolBuilder.Model.Field;

namespace ProtocolBuilder.Model.Setting
{
    /// <summary>
    /// The setting include some parameters for creating the field instance.
    /// </summary>
    class NormalSetting : IBuildFieldSetting
    {
        public string TypeName { get; set; }
        public string FieldName { get; set; }
        public string Description { get; set; }

        public NormalSetting(string type, string fieldName, string description)
        {
            this.TypeName = type;
            this.FieldName = fieldName;
            this.Description = description;
        }

        #region IBuildFieldSetting 成员

        public AbsField BuildField()
        {
            AbsField result = FieldFactory.CreateField(this.TypeName);
            result.FieldName = this.FieldName;
            result.Description = this.Description;

            return result;
        }

        public bool CanHasChildren
        {
            get
            {
                return this.BuildField().CanHasChildren;
            }
        }

        #endregion
    }
}
